<%--
  Created by IntelliJ IDEA.
  User: acer
  Date: 2024/9/19
  Time: 9:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" import="java.util.*" pageEncoding="UTF-8" import="java.text.*" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>使用application内置对象--checkMessage.jsp</title>
</head>
<body bgcolor="#abcdel">
<%!Vector<String> v = new Vector<String>();
    int i = 0;
%>
<%
    String datetime = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(Calendar.getInstance().getTime());
%>
<%
    request.setCharacterEncoding("UTF-8");
    String name = request.getParameter("name");
    String title = request.getParameter("title");
    String message = request.getParameter("message");
%>
<%
    if (name == null ||"".equals(name.trim())){
        //trim() 方法用于解决里面只有空格的问题
        name = "网友" + (int)(Math.random() * 100000 + 10000);
    }
    if (title == null || "".equals(title.trim())){
        title = "无";
    }
    if (message == null || "".equals(message.trim())){
        message = "无";
    }
%>
<%
    i++;
    String str = "第" + i + "条留言：" + name + " 留言：" + title + " 留言内容：" + message + " 留言时间：" + datetime;
    v.add(str);
    application.setAttribute("message", v);
%>
留言成功.
<a href="inputMessage.jsp">返回留言板</a>
</body>
</html>
